/**
  ******************************************************************************
  * @file    Libraries/Device/TS32Fx/TS32Fx_LL_Driver/src/ts32fx_ll_div.c
  * @author  TOPSYS Application Team
  * @version V1.0.0
  * @date    02-11-2018
  * @brief   This file contains all the div LL firmware functions.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2018 TOPSYS</center></h2>
  *
  *
  *
  ******************************************************************************
  */ 

/* Includes ------------------------------------------------------------------*/
#include "include.h"

/** @addtogroup TS32Fx_StdPeriph_Driver TS32Fx Driver
  * @{
  */
  
/** @defgroup div_interface_gr DIV Driver
  * @ingroup  TS32Fx_StdPeriph_Driver
  * @{
  */

/** @addtogroup DIV_LL_Driver DIV LL Driver
  * @ingroup  div_interface_gr
  * @{
  */
  
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

  
/** @defgroup DIV_LL_Interrupt DIV LL Interrupt Handle function
  * @ingroup  DIV_LL_Driver
  * @brief   DIV LL Interrupt Handle function
  * @{
  */



/**
  * @}
  */

/** @defgroup DIV_LL_Inti_Cfg DIV LL Initialization And Configuration
  * @ingroup  DIV_LL_Driver
  * @brief    DIV LL Initialization And Configuration
  * @{
  */

/**
  * @brief  opam init
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @param  p_init: pointer to the init stuct TYPE_LL_OPAM_INIT
  * @retval None
  */
void ll_opam_init(OPAM_TypeDef *p_opam, TYPE_LL_OPAM_INIT *p_init)
{
    u32 opam_con = 0;
    opam_con = OPAM->CON;
    opam_con = (opam_con & (~LL_OPAM_CON_AINX_SEL(ALL_WORD_FF))) | LL_OPAM_CON_AINX_SEL(p_init->ainx_sel);
    opam_con = (opam_con & (~LL_OPAM_CON_BINX_SEL(ALL_WORD_FF))) | LL_OPAM_CON_BINX_SEL(p_init->binx_sel);
    if(p_init->trim_en)
    {
        opam_con = (opam_con & (~LL_OPAM_CON_TRIMS_SET(ALL_WORD_FF))) | LL_OPAM_CON_TRIMS_SET(p_init->trim_value);
        opam_con |= LL_OPAM_CON_TRIM_EN;
    }
    else
    {
        opam_con &= ~LL_OPAM_CON_TRIM_EN;
    }
    
    if(p_init->low_power_en)
    {
        opam_con |= LL_OPAM_CON_LOWP_EN;
    }
    else
    {
        opam_con &= ~LL_OPAM_CON_LOWP_EN;
    }
    
    if(p_init->opam_en)
    {
        opam_con |= LL_OPAM_CON_EN;
    }
    else
    {
        opam_con &= ~LL_OPAM_CON_EN;
    }
    OPAM->CON = opam_con;
}

/**
  * @brief  operational amplifier enable
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_enable(OPAM_TypeDef *p_opam)
{
    p_opam->CON |= LL_OPAM_CON_EN;
}

/**
  * @brief  operational amplifier disable
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_disable(OPAM_TypeDef *p_opam)
{
    p_opam->CON &= ~LL_OPAM_CON_EN;
}
/**
  * @brief  operational amplifier adaptive calibration enable
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_trim_enable(OPAM_TypeDef *p_opam)
{
    p_opam->CON |= LL_OPAM_CON_TRIM_EN;
}

/**
  * @brief  operational amplifier adaptive calibration disable
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_trim_disable(OPAM_TypeDef *p_opam)
{
    p_opam->CON &= ~LL_OPAM_CON_TRIM_EN;
}

/**
  * @brief  operational amplifier low power enable
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_lowp_enable(OPAM_TypeDef *p_opam)
{
    p_opam->CON |= LL_OPAM_CON_LOWP_EN;
}

/**
  * @brief  operational amplifier low power disable
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_lowp_disable(OPAM_TypeDef *p_opam)
{
    p_opam->CON &= ~LL_OPAM_CON_LOWP_EN;
}

/**
  * @brief  operational amplifier register lock enable(only set it once)
  * @param  p_opam : pointer to the hardware OPAM_TypeDef
  * @retval None
  */
void ll_opam_lock_enable(OPAM_TypeDef *p_opam)
{
    p_opam->CON |= LL_OPAM_CON_LOCK_EN;
}


/**
  * @}
  */

/** @defgroup DIV_LL_Data_Transfers DIV LL Data transfers functions
  * @ingroup  DIV_LL_Driver
  * @brief    DIV LL Data transfers functions
  * @{
  */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/*************************** (C) COPYRIGHT 2018 TOPSYS ***** END OF FILE *****/
